package me.predatorray.xcollection;

import java.util.Collection;
import java.util.Iterator;

abstract class CollectionDelegate<E> implements Collection<E> {

    private final Collection<E> delegated;

    CollectionDelegate(Collection<E> delegated) {
        Check.isNotNull(delegated, "Cannot delegate a null object");
        this.delegated = delegated;
    }

    @Override
    public int size() {
        return delegated.size();
    }

    @Override
    public boolean isEmpty() {
        return delegated.isEmpty();
    }

    @Override
    public boolean contains(Object o) {
        return delegated.contains(o);
    }

    @Override
    public Iterator<E> iterator() {
        return delegated.iterator();
    }

    @Override
    public Object[] toArray() {
        return delegated.toArray();
    }

    @Override
    public <T> T[] toArray(T[] a) {
        return delegated.toArray(a);
    }

    public boolean add(E e) {
        return delegated.add(e);
    }

    @Override
    public boolean remove(Object o) {
        return delegated.remove(o);
    }

    @Override
    public boolean containsAll(Collection<?> c) {
        return delegated.containsAll(c);
    }

    public boolean addAll(Collection<? extends E> c) {
        return delegated.addAll(c);
    }

    @Override
    public boolean removeAll(Collection<?> c) {
        return delegated.removeAll(c);
    }

    @Override
    public boolean retainAll(Collection<?> c) {
        return delegated.retainAll(c);
    }

    @Override
    public void clear() {
        delegated.clear();
    }

    @Override
    public boolean equals(Object o) {
        return delegated.equals(o);
    }

    @Override
    public int hashCode() {
        return delegated.hashCode();
    }
}
